﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Galoap;

namespace WebService
{
    public partial class Stats : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Galoap.UnitTest.Storage.DatabaseFill.Fill();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            DateTime selected = new DateTime(Convert.ToInt32(DropDownList3.SelectedItem.Value), Convert.ToInt32(DropDownList2.SelectedItem.Value), Convert.ToInt32(DropDownList1.SelectedItem.Value));

            try{Label3.Text = Statistics.GetGameSessionsPlayedByDate(selected).ToString();}catch (Exception) { Label3.Text = "0"; }
            try{Label4.Text = Statistics.GetNumberOfGamesPlayedOnDate(selected).ToString();}catch (Exception) { Label4.Text = "0"; }
            try{Label5.Text = Statistics.GetNumberOfActiveUsersOnDate(selected).ToString();}catch (Exception) { Label5.Text = "0"; }
            try{Label6.Text = Statistics.GetUserWithHighestScoreByDate(selected).NickName;}catch (Exception) { Label6.Text = "0"; }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            DateTime selected = new DateTime(Convert.ToInt32(DropDownList6.SelectedItem.Value), Convert.ToInt32(DropDownList5.SelectedItem.Value), Convert.ToInt32(DropDownList4.SelectedItem.Value));

            try { Label8.Text = Statistics.GetNumberOfGameSessionsByUserOnDate(selected,TextBox1.Text).ToString(); }catch (Exception) { Label8.Text = "0"; }
            try { Label9.Text = Statistics.GetNumberOfAnswersByUserOnDate(selected,TextBox1.Text).ToString(); }catch (Exception) { Label9.Text = "0"; }
            try { Label10.Text = Statistics.GetNumberOfGamesPlayedByUser(TextBox1.Text).ToString(); } catch (Exception) { Label10.Text = "0"; }
        }
    }
}
